1. Field of the Invention
The present description relates to a computer program product, system, and method for managing multiple processor threads of one or more processors.
2. Description of the Related Art
Programmed instructions are often executed by a processor in one or more sequences of instructions. A scheduler of an operating system or other type of scheduler typically gives access to system resources such as processor, memory and communication resources for purposes of executing the instructions. The smallest sequence of programmed instructions which can be managed independently by a scheduler is frequently referred to as a “Central Processing Unit (CPU) thread”. A process may include one or more such CPU threads.
A multi-processor or multi-core system can frequently execute multiple CPU threads concurrently so that multiple instructions are executed in parallel, thereby often improving system performance. In general, the more instructions that can be executed in parallel, the larger the gain in performance.
However, CPU threads of programming code which are executing concurrently may in some applications utilize various techniques for synchronizing the execution of CPU threads. For example, if two or more CPU threads are sharing a shared resource such as a shared memory resource, for example, techniques such as spin locks are frequently employed to prevent attempts to access the shared resource by more than one CPU thread at a time.
If a CPU thread is accessing the shared resource, the spin lock indicates to other CPU threads attempting to access the shared resource that the shared resource is busy. Once the shared resource is no longer busy, the spin lock permits another CPU thread to access the shared resource. As a result, the CPU thread or threads denied access to the shared resource may be relegated to continually checking the spin lock to determine whether or not the spin lock indicates that the shared resource is still busy. Waiting and checking by other CPU threads for access to the spin lock is often referred to as “spinning” and may adversely affect system performance while the CPU threads “spin.” As the number of CPU threads in multi-processor systems grow, conflicts over shared resources and resultant performance loss may offset performance gains provided by additional CPU threads.
One approach to reduce contention over shared resources is to break spin locks into multiple, lower granularity locks. However, such an approach may require rewriting the programming code in such a manner as to significantly increase the complexity of the programming code. Moreover, changes to algorithms to accommodate the multiple, low granularity locks may adversely affect system performance as well.
Another approach is to experiment with different numbers of operating CPU threads. For example, in one experiment, the system may be operated with 32 CPU threads and the resultant system performance may be measured. In another experiment, the system may be operated with 64 CPU threads and the resultant system performance may be measured. The number of operating CPU threads, either 32 or 64, which gave the better system performance may be selected. However, the selected number of operating CPU threads may not be optimal for all operating conditions. For example, 32 CPU threads may provide better performance than 64 CPU threads for one level or type of workload of the system, and 64 CPU threads may provide better performance than 32 CPU threads for the same system but with a different level or type of workload. Thus, selecting an appropriate number of operating CPU threads for a given system may be difficult.